package com.ruimei.service.impl;

import com.ruimei.entitys.Honor;
import com.ruimei.mapper.HonorMapper;
import com.ruimei.service.HonorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class HonorServiceImpl implements HonorService {

    @Resource
    HonorMapper honorMapper;

    @Override
    public Map<String, Object> addHonor(Honor honor) {
        Map<String, Object> map = new HashMap();
        Integer i = honorMapper.addHonor(honor);
        if(i.intValue() == 1){
            map.put("status", Boolean.valueOf(true));
            map.put("message", "添加成功");
        }else{
            map.put("status", Boolean.valueOf(false));
            map.put("message", "添加失败");
        }

        return map;
    }

    @Override
    public Map<String, Object> getHonorByStudnetId(String studentId) {
        Map<String, Object> map = new HashMap();
        List<Honor> list = honorMapper.getHonor(studentId,null,null);

        map.put("status", Boolean.valueOf(true));
        map.put("message", "查询成功");
        map.put("count", Integer.valueOf(list.size()));
        map.put("data", list);

        return map;

    }

    @Override
    public Map<String, Object> getHonorByClassId(String classId,String studentName) {
        Map<String, Object> map = new HashMap();
        List<Honor> list = honorMapper.getHonor(null,classId,studentName);

        map.put("status", Boolean.valueOf(true));
        map.put("message", "查询成功");
        map.put("count", Integer.valueOf(list.size()));
        map.put("data", list);

        return map;
    }
}
